#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from inary.actionsapi import autotools
from inary.actionsapi import inarytools
from inary.actionsapi import shelltools
from inary.actionsapi import get
import os

def setup():
    options = """--prefix=/usr --enable-cxx \
               --enable-fat"""
    print(os.environ)
    if get.buildTYPE() == "emul32":
        shelltools.export("HOST", "x86_64-linux-gnu")
        shelltools.export("CC", "gcc -m32")
        shelltools.export("CXX", "g++ -m32")
        inarytools.reset_env()
        shelltools.export("ABI", "32")
        options+=""" --libdir=/usr/lib32"""

    autotools.rawConfigure(options)

def build():
    autotools.make()

def check():
    autotools.make("check")

def install():
    autotools.rawInstall("DESTDIR=%s" % get.installDIR())

    if get.buildTYPE() == "emul32": return

    inarytools.doinfo("doc/*info*")
    inarytools.dodoc("AUTHORS", "ChangeLog", "COPYING*", "NEWS", "README")
